package com.example.spider.task.limit;

import com.example.spider.task.AbstractSpiderTask;
import com.example.spider.task.Task;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 *
 * @author lym
 */
@JsonSerialize(using = LimitStrategyJsonSerializer.class)
@JsonDeserialize(using = LimitStrategyJsonDeserializer.class)
public interface LimitStrategy {

    String getKey();

    boolean needLimit(Task<?> task);

    void doLimit(AbstractSpiderTask<?> task);

    <T> void afterRequest(Task<T> task, T result, Throwable ex, long endTime);

    LimitStrategy copyWithNewKey(String s);
}
